package com.xy.annotaion.handler.kotlin.compiler.demo1

import java.io.IOException

class ParseException : Exception {

    constructor(t: Token) : this("", t)
    constructor(msg: String, t: Token) : super("syntax error around ${location(t)}. $msg")
    constructor(e: IOException) : super(e)
    constructor(msg: String) : super(msg)


    companion object {
        fun location(t: Token): String {
            if (t == Token.EOF) {
                return "the last line"
            } else {
                return "\"${t.getText()}\" at line ${t.getLineNumber()}"
            }
        }
    }

}
